By n8n
Public Lead API — Integration with n8n
This guide explains how to integrate the Public Lead API into n8n. Unlike Make.com, which is very user-friendly, n8n often requires some technical or developer experience. You may need to configure API credentials manually (Client ID, Client Secret, etc.).
Important Notes
Google Sheets are supported with proper credentials.
- You will still need to use an HTTP Request node to send data to the Public Lead API.
-
Search for Facebook Lead Ads Trigger
- In n8n, add a node: Facebook Lead Ads Trigger.
-
Set up Credentials
-
In the node’s Credentials section, click Create New.
-
You must have a Meta Developer Account and a registered App.
-
From your Meta App, copy:
- Client ID
- Client Secret
-
Paste them into the n8n credentials fields.
-
Save the credentials.
-
Click Connect. A login window will appear to sign in with your Meta account.
-
After signing in, save the connection.
-
-
Choose Page and Form
- Back in the node, select the Page and Form you want to listen to.
- The trigger will now capture new leads.
-
Send to Public Lead API
-
Add an HTTP Request node.
-
Configure it:
- Method:
POST - URL:
your-domain/api/create-lead - Response Format:
JSON
- Method:
-
In the Body Parameters, paste the JSON schema:
{
"organizationId": "",
"name": "",
"sourceMethod": "",
"phone": "",
"email": "",
"comments": [],
"info": {},
"mainSourceId": "",
"mainSourceName": "",
"campaignId": "",
"campaignName": "",
"adGroupId": "",
"adGroupName": "",
"adId": "",
"adName": ""
} -
Map the fields from the Facebook Lead Ads Trigger into the correct JSON keys.
-
Google Sheets → Public Lead API
-
Search for Google Sheets
- In n8n, add a Google Sheets Trigger node.
- Scroll down and choose On Added Row.
-
Set up Credentials
- Click Add New Credentials.
- You will need a Client ID and Client Secret from a Google Cloud project.
- Follow this video to learn how to generate them: How to get Google API Client ID and Secret
- Paste the values in n8n.
- Authenticate by signing into your Google account.
-
Select Spreadsheet
- After signing in, select the Spreadsheet and Worksheet you want to monitor.
- The trigger will fire when a new row is added.
-
Send to Public Lead API
- Add an HTTP Request node.
- Configure it exactly the same as in the Facebook section (URL, POST, JSON schema).
- Map the spreadsheet columns into the JSON fields.
About mainSourceId and mainSourceName
In the JSON schema, you’ll notice two fields:
"mainSourceId": "",
"mainSourceName": ""
These represent the exact source of the lead:
- Meta (Facebook/Instagram) →
mainSourceId= Page ID,mainSourceName= Page Name - Google Sheets →
mainSourceIdcan be the Sheet ID,mainSourceNamethe Sheet Name - Other platforms → could be Form IDs, Ad Set names, etc.
This helps you track exactly which source generated the lead.